<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<%@include file="/common/repairAddress.jsp" %>
<!DOCTYPE html>
<html>
<head>
<title>应急抢修--${fns:getConfig('productName')}</title>
<%@include file="/common/uihead.jsp" %>
<%@include file="/common/upload.jsp" %>
<script src="${ctxStatic}/js/public/public.js" type="text/javascript"></script>
</head>
<body>
	<ul class="nav nav-tabs" style="margin:0 4px 4px 4px;">
		<c:forEach items="${list}" var="menu"  varStatus="idxStatus">
			<li class="${menu.tag eq tag?'active':''}">
				<a href="${ctx}/${menu.href}${fn:indexOf(menuChild.href, '?') eq -1?'?':'&'}left=${fns:encodeParamUrl(left)}&top=${fns:encodeParamUrl(top)}&parentId=${fns:encodeParamUrl(parentId)}&LId=${fns:encodeParamUrl(LId)}&filter_EQS_tag=${menu.tag}">
					<i class="icon icon-list" style="margin-right:10px"></i><span>${menu.name}</span>
				</a>
			</li>
		</c:forEach>
	</ul>
    <tags:message content="${msg}" />
<form id="mainForm" class="form-horizontal" role="form" method="get"  name="mainForm">
<div class="breadcrumb form-search" style="background-color: #f5f5f5;">
			<div>
				<label>关键字:</label>
				<input type="text" oninput="queryForGrid('mainForm','jqGrid')" onporpertychange="queryForGrid('mainForm','jqGrid')"  name="filter_LIKES_year_OR_year" value="${filter_LIKES_year_OR_year}" placeholder="年份查询" />
				<sec:authorize ifAnyGranted="ROLE_lwfw_lwbt_yjqt_editor">
					<a href="#javascript:void(0)" onclick= "openPublicModal();"  class="btn btn-primary" role="button" >新增&nbsp;</a>
				</sec:authorize>
			</div>
		</div>
  <table id="jqGrid"></table>
  <div id="jqGridPager"></div> 
</form>
<form id="publicForm" name="publicForm">
   <input type="hidden" name="token" value="${token}" id="token">
   <input type="hidden" name="id" id="id" value="">
   <input type="hidden" name="tag" id="tag" value="${tag}">
<div class="modal fade" id="publicModal" tabindex="-1" role="dialog" aria-labelledby="publicModal" aria-hidden="true" data-backdrop="static" style="width:1000px;max-height:700px">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title" id="myModalLabel">新增/修改</h4>
					</div>
					<div class="modal-body" style="max-height:670px;">
						<table class="table"  style="border: none;margin-bottom: -14px">
							<tbody>
								<tr>
									<td style="width:105px;">年份<font color="red">&nbsp;*</font>：</td>
									<td style="width:320px">
										<input  id="year" name="year" value="" 
										onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy',maxDate:'%y'})" class="Wdate required" type="text"/>
									</td>
									<td style="width:160px;">上报事件数量（起）<font color="red">&nbsp;*</font>：</td>
									<td style="width:320px">
										<input name="reportNum" id="reportNum" type='text' maxlength="6" class="required"  onkeyup="enfocus()"/>
									</td>
								</tr>
								<tr>
									<td>满足时限恢复数量（起）<font color="red">&nbsp;*</font>：</td>
									<td style="width:320px">
										<input id="restoreNum" name="restoreNum" type="text" maxlength="6"  class="required" onkeyup="enfocus()"/>
									</td>
								<tr>
								<tr>
									<td>备　　注:</td>
									<td colspan="3">
										<div class="wordCount wyInline" id="wordCount">
											<textarea placeholder="" rows='3' id="remark" name="remark"></textarea>
											<span class="wordwrap"><var class="word">200</var>/200</span>
										</div>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="modal-footer" style="padding:4px 15px 5px;">
						<button type="button" class="btn btn-default" data-dismiss="close">关闭</button>
						<button type="button" class="btn btn-danger" onclick='publicDel("${ctx}/emergRepair/delete.do");' style="display:none;" id="delPublic">删除</button>
						<button type="submit" class="btn btn-primary" id="subPublic" >提交</button>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal -->
		</div>
</form>
	<script type="text/javascript">
	    var path = "${ctx}";
	    var tag = "${tag}";
		$(document).ready(function()
		{
			var jqgridH = $(window).height()-345;    
			$("#publicForm").validate({
				rules: {
					year:{
						remote:{
							url:'${ctx}/emergRepair/checkYear.do',
							type:'POST',
							data:{
								id:function(){return $('#id').val();}
							}
						}
					},
					reportNum:{
						min:0,
						digits:true,
						max : 999999,
						repCompare:true
					},
					restoreNum:{
						min:0,
						digits:true,
						max : 999999,
						resCompare:true
					},
					
					ratio:{
						max:100
					}
				},
				messages: {
					year:{remote:'该年份已经存在'},
				},
				submitHandler:function(form){
						//$('#subPublic').attr('disabled','disabled');  //防止重复提交，请求完毕之前禁用提交按钮
						var url ="${ctx}/emergRepair/save.do";
						publicSubmit(url);
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			jQuery.validator.addMethod("repCompare", function(value,element) {
                var restoreNum = $("#restoreNum").val();
              return this.optional(element)  || restoreNum == '' || parseInt(value) >= parseInt(restoreNum) ;   
            }, $.validator.format("上报数量应大于或等于恢复数量"));
			jQuery.validator.addMethod("resCompare", function(value,element) {
                var reportNum = $("#reportNum").val();
              return this.optional(element)  || reportNum == '' || parseInt(value) <= parseInt(reportNum) ;   
            }, $.validator.format("恢复数量应小于或等于上报数量"));
			
			$("#jqGrid").jqGrid(
			{ url : '${ctx}/emergRepair/list.do',
			  mtype : "GET",
			  datatype : "json",
			  page : 1,
			  viewrecords: true,
			  colModel:[
				<sec:authorize ifAnyGranted="ROLE_lwfw_lwbt_yjqt_editor">
				{ label : "操作", name : "id", 
					  width : 80,   align : 'center', sortable : false, search : false ,
					  classes:'ui-jqgrid-optClass',
					  formatter: function (cellValue, options, rowObject){
							return formatterOpt(cellValue);
					  }
				},
				</sec:authorize>
				{ label : "文件", name : "id", 
					  width : 100,   align : 'center', sortable : false, search : false ,
					  classes:'ui-jqgrid-optClass',
					  formatter: function (cellValue, options, rowObject){
							return "<a href='javascript:void(0);' onclick='openModal(\"T_LWFW_EMERGDREPAIR\",\"" + cellValue+"\",\"" + rowObject['projectName']+"\");' role='button' >"+
							"<i class='icon-upload' style='margin-top:4px'></i>&nbsp;上传附件</a>";
					  }
				},{
					label:'年份',
					name: 'year',
					align:'center',
					width:100,
					formatter:function(cellValue,options,rowObject){
	      	        	return "<span style='font-weight:bolder'>"+cellValue+"</span>";
	      	        }
				},{
				     label: '上报事件数量（起）',
				     name: 'reportNum',
				  	 align:'center',
				     width: 190,
				},{
					label:'恢复事件满足时限要求数量（起）',
					name: 'restoreNum',
					align:'center',
					width:270
				},{
				     label: '比例（%）',
				     name: 'ratio',
				  	  align:'center',
				     width: 130,
				},{
				     label: '备注',
				     name: 'remark',
				  	 align:'center',
				     width: 260,
				     sortable:false
				}
			],
			autowidth : false,width:$(window).width()-248, height : jqgridH,scrollOffset:0, shrinkToFit : 400, rowNum : 10, viewrecords : true, rownumbers : true,
			jsonReader:{
    			root: "result",
    			page: "currentPage",
    			total: "totalPages",
    			records: "totalCount",
    			repeatitems: true,
    			cell: "cell",
    			id: "id",
    			userdata: "userdata",
    			subgrid: {root:"results", repeatitems: true, cell:"cell"}
    		},
    		prmNames: {
				page:"pageNo",
				rows:"pageSize",
				sort: "orderBy",
				order: "order",
				search:"_search",
				nd:"nd", id:"id",
				oper:"oper",
				editoper:"edit",
				addoper:"add",
				deloper:"del",
				subgridid:"id",
				npage: null,
				totalrows:"totalCounts"
			}, 
			rowList :[10,20,30], 
			pager : "#jqGridPager"
			});
		});
		
	function formatterOpt(id) {
		return "<a href='javascript:void(0);' onclick='updatePublic(\"" + id
				+ "\",\"${ctx}/emergRepair/show.do\");' id='" + id
				+ "'  title='修改'><i class='icon icon-edit' style='margin-top:4px;'></i>&nbsp;修改</a>";
	}
</script>
<jsp:include page="/WEB-INF/views/system/attachment.jsp"/> 
</body>
</html>
